package cn.ncu.wechat.controller;

import cn.ncu.wechat.service.ArticleService;
import cn.ncu.wechat.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/admin/articles")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @GetMapping("/{id}")
    public Result getArticleDetail(@PathVariable Long id) {
        return articleService.getArticleDetail(id);
    }

    @PostMapping("/{id}/status")
    public Result changeStatus(@PathVariable Long id, @RequestBody Map<String, Integer> request) {
        Integer status = request.get("status");
        System.out.println(id);
        return articleService.changeStatus(id, status);
    }

}
